<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //基本数据类型：布尔型，数值型，字符型，空型（null）,未定义型
    console.log('------------数字开头的字符串-------------')
    let num1='12.345asdf';
    let num2=Number(num1),num3=parseInt(num1),num4=parseFloat(num1);
    console.log(num2);          //NaN:Not a Number
    console.log(typeof(num2));  //类型：number
    console.log(num3);          //12
    console.log(typeof(num3));  //类型：number
    console.log(num4);          //12.345
    console.log(typeof(num4));  //类型：number
    console.log('------------纯数字字符串-------------')
    let num11='555';
    let num12=Number(num11),num13=parseInt(num11),num14=parseFloat(num11);
    console.log(num12);          //555
    console.log(typeof(num12));  //类型：number
    console.log(num13);          //555
    console.log(typeof(num13));  //类型：number
    console.log(num14);          //555
    console.log(typeof(num14));  //类型：number
    console.log('------------空字符串-------------')
    let num21='';
    let num22=Number(num21),num23=parseInt(num21),num24=parseFloat(num21);
    console.log(num22);          //0
    console.log(typeof(num22));  //类型：number
    console.log(num23);          //NaN
    console.log(typeof(num23));  //类型：number
    console.log(num24);          //NaN
    console.log(typeof(num24));  //类型：number
    console.log('------------非数字开头的字符串-------------')
    let num31='asdf123';
    let num32=Number(num31),num33=parseInt(num31),num34=parseFloat(num31);
    console.log(num32);          //NaN
    console.log(typeof(num32));  //类型：number
    console.log(num33);          //NaN
    console.log(typeof(num33));  //类型：number
    console.log(num34);          //NaN
    console.log(typeof(num34));  //类型：number
    console.log('------------null-------------')
    let str11=null;
    let num42=Number(str11),num43=parseInt(str11),num44=parseFloat(str11);
    console.log(num42);          //0
    console.log(typeof(num42));  //类型：number
    console.log(num43);          //NaN
    console.log(typeof(num43));  //类型：number
    console.log(num44);          //NaN
    console.log(typeof(num44));  //类型：number
    console.log('------------undefined-------------')
    let str21=undefined;
    let num52=Number(str21),num53=parseInt(str21),num54=parseFloat(str21);
    console.log(num52);          //NaN
    console.log(typeof(num52));  //类型：number
    console.log(num53);          //NaN
    console.log(typeof(num53));  //类型：number
    console.log(num54);          //NaN
    console.log(typeof(num54));  //类型：number
    console.log('------------false-------------')
    let str31=false;
    let num62=Number(str31),num63=parseInt(str31),num64=parseFloat(str31);
    console.log(num62);          //0
    console.log(typeof(num62));  //类型：number
    console.log(num63);          //NaN
    console.log(typeof(num63));  //类型：number
    console.log(num64);          //NaN
    console.log(typeof(num64));  //类型：number
    console.log('------------true-------------')
    let str41=true;
    let num72=Number(str41),num73=parseInt(str41),num74=parseFloat(str41);
    console.log(num72);          //1
    console.log(typeof(num72));  //类型：number
    console.log(num73);          //NaN
    console.log(typeof(num73));  //类型：number
    console.log(num74);          //NaN
    console.log(typeof(num74));  //类型：number

    console.log('----------转字符型------------')
    let str1=null,str2=undefined,str3=true,str4=123.56;
    console.log(String(str1));
    console.log(String(str2));
    console.log(String(str3));
    console.log(String(str4));
    // console.log(str1.toString());   //报错
    // console.log(str2.toString());   //报错
    console.log(str3.toString());
    // console.log(str4.toString());   //报错
    // console.log(str5.toString());   //报错
   
</script>
</html>